
using System.Collections;
using QdbUnit.Extensions;
using Qdb.Config;
using Qdb.Tests.Jre5.Collections.Typehandler;
using Qdb.Typehandlers;

namespace Qdb.Tests.Jre5.Collections.Typehandler
{
	public class ListTypeHandlerPersistedCountTestCase : AbstractQdbTestCase
	{
		public static void Main(string[] args)
		{
			new ListTypeHandlerPersistedCountTestCase().RunAll();
		}

		public class TypedItem
		{
			internal ArrayList list;
		}

		public class InterfaceItem
		{
			internal IList list;
		}

		public class UntypedItem
		{
			internal object list;
		}

		/// <exception cref="System.Exception"></exception>
		protected override void Configure(IConfiguration config)
		{
			config.RegisterTypeHandler(new SingleClassTypeHandlerPredicate(typeof(ArrayList))
				, new CollectionTypeHandler());
		}

		public virtual void TestTypedItem()
		{
			ListTypeHandlerPersistedCountTestCase.TypedItem typedItem = new ListTypeHandlerPersistedCountTestCase.TypedItem
				();
			typedItem.list = new ArrayList();
			Store(typedItem);
			QdbAssert.PersistedCount(1, typeof(ArrayList));
		}

		public virtual void TestInterFaceItem()
		{
			ListTypeHandlerPersistedCountTestCase.InterfaceItem interfaceItem = new ListTypeHandlerPersistedCountTestCase.InterfaceItem
				();
			interfaceItem.list = new ArrayList();
			Store(interfaceItem);
			QdbAssert.PersistedCount(1, typeof(ArrayList));
		}

		public virtual void TestUntypedItem()
		{
			ListTypeHandlerPersistedCountTestCase.UntypedItem untypedItem = new ListTypeHandlerPersistedCountTestCase.UntypedItem
				();
			untypedItem.list = new ArrayList();
			Store(untypedItem);
			QdbAssert.PersistedCount(1, typeof(ArrayList));
		}
	}
}
